#include <Arduino.h>
#include <PD_UFP.h>
#include <Wire.h>

class PD_UFP_c PD_UFP;

float start_verilog = 3.4;

float verilog = start_verilog;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  PD_UFP.init_PPS(PPS_V(verilog), PPS_A(3.0));
  PD_UFP.clock_prescale_set(2);

  pinMode(0, INPUT_PULLUP);
}

void loop() {
  PD_UFP.run();

  if (digitalRead(0) == LOW) {
    delay(5);
    if (digitalRead(0) == LOW) {
      verilog += 0.3;
      if (verilog > 15.0) verilog = start_verilog;

      PD_UFP.set_PPS(PPS_V(verilog), PPS_A(3.0));

      Serial.printf("电压为：%.1f \n", verilog);
    }
    while (digitalRead(0) == LOW)
      ;
    while (!PD_UFP.is_PPS_ready()) delay(5);
  }
}